import React, { Component } from "react";
import { DatePicker } from "antd";
import Label from "../LabelDecorator";

@Label()
class FormDatePicker extends Component {
  render() {
    const { getData, labelWidth } = this.props;
    const dateFormat = getData("dateFormat") || [];
    const timeFormat = getData("timeFormat") || [];
    const showTime = timeFormat.length > 0;
    const format = `${dateFormat.join("-")} ${timeFormat.join(":")}`;
    return (
      <DatePicker
        format={format}
        showTime={showTime}
        size={getData('size')}
        style={{ width: `calc(100% - ${labelWidth}px)` }}
      />
    );
  }
}

export default FormDatePicker;
